<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script src="js/vue.js"></script>
    <script src="js/axios-0.18.0.js"></script>

</head>
<body>
    <div id="app">
        <table>
            <tr>
                <th>姓名</th>
                <th>票数</th>
                <th>操作</th>
            </tr>
            <tr v-for="man in welMans">
                <td>{{man.name}}</td>
                <td>{{man.score}}</td>
                <td><button @click="send(man.name,man.score)">投一票</button></td>
            </tr>
        </table>
    </div>
</body>

<script>
    new Vue({
        el:"#app",
        data:{
            welMans:[]
        },
        mounted(){
            this.getMans();
        },
        methods:{
            getMans(){
                axios.get("/wel")
                .then(resp=>{
                    this.welMans = resp.data.data;
                });
            },
            send(name,score){
                axios.post("/wel/incr","name="+name+"&score="+score)
                .then(resp=>{
                    //重新查询
                    this.getMans();
                });
            }

        }
    });
</script>
</html>